﻿#include "grid.h"

Grid::Grid() {
    hasMine = false;
    isSweeped = false;
    isSteped = false;
    isMarked = false;
    numOfMine = 0;
}

void Grid::updateGrid() {
    if (isSweeped) {
        if (hasMine) {
            this->setPixmap(QPixmap(MINE_STEP));
        } else {
            if (numOfMine == 0)
                setPixmap(QPixmap(MINE_0));
            if (numOfMine == 1)
                setPixmap(QPixmap(MINE_1));
            if (numOfMine == 2)
                setPixmap(QPixmap(MINE_2));
            if (numOfMine == 3)
                setPixmap(QPixmap(MINE_3));
            if (numOfMine == 4)
                setPixmap(QPixmap(MINE_4));
            if (numOfMine == 5)
                setPixmap(QPixmap(MINE_5));
            if (numOfMine == 6)
                setPixmap(QPixmap(MINE_6));
            if (numOfMine == 7)
                setPixmap(QPixmap(MINE_7));
            if (numOfMine == 8)
                setPixmap(QPixmap(MINE_8));
            if (numOfMine == 9)
                setPixmap(QPixmap(MINE_9));
        }
    } else {
        if (isMarked){
            setPixmap(QPixmap(FLAG));
        } else{
            setPixmap(QPixmap(NOTSWEEP));
        }
    }
}

void Grid::initGrid() {
    hasMine = false;
    isSweeped = false;
    isSteped = false;
    isMarked = false;
    numOfMine = 0;
}
